<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .v {
            width: 60%;
            height: 60vh;
            background-image: linear-gradient(-35deg, #df6c8c, #ccc, #b3f77b, #bbb);
            position: relative;
            margin: 0 auto;
        }

        .v>input {
            width: 100px;
            height: 100px;
            position: absolute;
            right: -120px;
            top: 50%;
            margin-top: -50px;
        }
    </style>
</head>

<body>
    <div class="v">
        <input type="button" value="关灯" id="btn">
    </div>
    <script>
        var btn = document.getElementById('btn')
        var isBlack = false;
        btn.onclick = function () {
            document.body.style.backgroundColor = isBlack ? '' : '#000';
            btn.value = isBlack ? '关灯' : '开灯';
            isBlack = !isBlack;
        }
    </script>
</body>

</html>